<template>
	<view style="margin-left: 15px;margin-right: 15px;">
		<u-form :model="student" ref="uForm">
			<u-form-item label="姓名" labelWidth="70px">
				<u-input v-model="student.name" :border="true" :disabled="true" />
			</u-form-item>
			<u-form-item label="性别" labelWidth="70px">
				<u-input v-model="student.gender" :border="true" :disabled="true" />
			</u-form-item>
			<u-form-item label="出生年月" labelWidth="70px">
				<u-input v-model="student.birth" :border="true" :disabled="true" />
			</u-form-item>
			<u-form-item label="身份证号" labelWidth="70px">
				<u-input v-model="student.idCard" :border="true" :disabled="true" />
			</u-form-item>
			<u-form-item label="学院" labelWidth="70px">
				<u-input v-model="calsses.structure.college" :border="true" :disabled="true" />
			</u-form-item>
			<u-form-item label="专业" labelWidth="70px">
				<u-input v-model="student.major" :border="true" :disabled="true" />
			</u-form-item>
			<u-form-item label="学号" labelWidth="70px">
				<u-input v-model="student.studentNumber" :border="true" :disabled="true" />
			</u-form-item>
			<u-form-item label="入学时间" labelWidth="70px">
				<u-input v-model="student.entrySchoolTime" :border="true" :disabled="true" />
			</u-form-item>
			<u-form-item label="手机号" labelWidth="70px">
				<u-input v-model="student.phonenum" :border="true" />
			</u-form-item>
			<u-form-item label="邮箱" labelWidth="70px">
				<u-input v-model="student.email" :border="true" />
			</u-form-item>
			<u-form-item label="住址" labelWidth="70px">
				<u-input v-model="student.address" :border="true" />
			</u-form-item>
			<u-form-item label="密码" labelWidth="70px">
				<u-input v-model="student.password" :border="true" type="password" />
			</u-form-item>
		</u-form>
		<u-button :custom-style="customStyle" type="primary" @click="submit">提交</u-button>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				customStyle: {
					marginTop: "50px",
					marginBottom: "50px",
				},
				student: {
					name: "",
					gender: "",
					birth: "",
					college: "",
					major: "",
					address: "",
					phonenum: "",
					email: "",
					calsses: {
						calsses: "",
						grade: "",
						id: "",
						structure: {
							college: "",
							major: "",
							id:""
						}
					},
					entrySchoolTime: "",
					idCard: "",
					studentNumber: "",
					password: "",
				},
			};
		},
		methods: {
			submit() {
				this.$axios.post("/api/v1/student/myinfo/update", this.student).then(r => {
					if (r.data.code == 200) {
						uni.showToast({
							title: '修改成功',
							icon: 'success'
						});
						setTimeout(() => {
							uni.switchTab({
								url: "/pages/my/my"
							})
						}, 1000)
					}
				})
			}
		},
		created() {
			this.$axios.get("/api/v1/student/myinfo/6").then(res => {
				console.log(res.data.data);
				this.student = res.data.data;
				this.calsses = res.data.data.classes;
				console.log(this.student);

			});

		}
	};
</script>

<style lang="scss">

</style>
